package ch.fhnw.kosmonauten.client.core;

import java.io.*;
import javax.swing.JFileChooser;
import javax.swing.JFrame;

import ch.fhnw.kosmonauten.model.Dossier;
/**
 * Dossier exportieren.
 * 
 * @author Fabian Siegrist
 * @author Oliver Freiermuth
 * @author Mikhail Onoufrienko
 * @author Risto Milani
 * @version $Revision: 95 $
 *          File name: $HeadURL: https://iching-kosmonauten.googlecode.com/svn/I-Ching/src/ch/fhnw/kosmonauten/server/net/dto/Transformation.java $
 *          Last modified:$Date: 2013-05-24 15:20:57 +0200 (Fri, 24 May 2013) $
 *          Last modified by: $Author: molotok.mihon@gmail.com $
 */

public class Export {

	public Export(Dossier newdossier) {

        
     // parent component of the dialog
        JFrame parentFrame = new JFrame();
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setDialogTitle("Specify a file to save");    
        int userSelection = fileChooser.showSaveDialog(parentFrame);
        String fileName = "";
        if (userSelection == JFileChooser.APPROVE_OPTION) {
            File fileToSave = fileChooser.getSelectedFile();
            fileName = fileToSave.getAbsolutePath();
        }
        
		try {
            // Assume default encoding.
            FileWriter fileWriter = new FileWriter(fileName);

            // Always wrap FileWriter in BufferedWriter.
            BufferedWriter bufferedWriter =
                new BufferedWriter(fileWriter);

            // Note that write() does not automatically
            // append a newline character.
        	bufferedWriter.write("DossierID: " + newdossier.getDossierID() + '\n' );
        	bufferedWriter.write("DossierName: " + newdossier.getDossierName() + '\n' );
        	bufferedWriter.write("UserID: " + newdossier.getUserID() + '\n' );
        	bufferedWriter.write("CategoryID: " + newdossier.getCategoryID() + '\n' );
        	bufferedWriter.write("Question: " + newdossier.getQuestion() + '\n' );
        	bufferedWriter.write("Analyse: " + newdossier.getAnalyse() + '\n' );
        	bufferedWriter.write("Synthese: " + newdossier.getSynthese() + '\n' );
        	bufferedWriter.write("Experience: " + newdossier.getExperience() + '\n' );
        	bufferedWriter.write("Hexagramcode: " + newdossier.getHexagramcode() + '\n' );
        	bufferedWriter.write("Binarycode: " + newdossier.getBinarycode() + '\n' );
        	bufferedWriter.write("BinarycodePerspective: " + newdossier.getBinarycodePerspective() + '\n' );
        	bufferedWriter.write("Privacy: " + newdossier.getPrivacy() + '\n' );
        	bufferedWriter.write("CreateDate: " + newdossier.getCreateDate() + '\n' );
        	bufferedWriter.write("EditDate: " + newdossier.getEditDate() + '\n' );
        	bufferedWriter.write("Situation: " + newdossier.getSituation() + '\n' );
        	bufferedWriter.write("Perspective: " + newdossier.getPerspective() + '\n' );
        	bufferedWriter.write("Nuclear: " + newdossier.getNuclear() + '\n' );
        	bufferedWriter.write("Inverse: " + newdossier.getInverse() + '\n' );
        	bufferedWriter.write("Reverse: " + newdossier.getReverse() + '\n' );
        	bufferedWriter.write("Fuxi: " + newdossier.getFuxi() + '\n' );
        	bufferedWriter.write("Sit_line1: " + newdossier.getSit_line1() + '\n' );
        	bufferedWriter.write("Sit_line2: " + newdossier.getSit_line2() + '\n' );
        	bufferedWriter.write("Sit_line3: " + newdossier.getSit_line3() + '\n' );
        	bufferedWriter.write("Sit_line4: " + newdossier.getSit_line4() + '\n' );
        	bufferedWriter.write("Sit_line5: " + newdossier.getSit_line5() + '\n' );
        	bufferedWriter.write("Sit_line6: " + newdossier.getSit_line6() + '\n' );
        	bufferedWriter.write("Per_line1: " + newdossier.getPer_line1() + '\n' );
        	bufferedWriter.write("Per_line2: " + newdossier.getPer_line2() + '\n' );
        	bufferedWriter.write("Per_line3: " + newdossier.getPer_line3() + '\n' );
        	bufferedWriter.write("Per_line4: " + newdossier.getPer_line4() + '\n' );
        	bufferedWriter.write("Per_line5: " + newdossier.getPer_line5() + '\n' );
        	bufferedWriter.write("Per_line6: " + newdossier.getPer_line6() + '\n' );
        	bufferedWriter.write("Nuc_line1: " + newdossier.getNuc_line1() + '\n' );
        	bufferedWriter.write("Nuc_line2: " + newdossier.getNuc_line2() + '\n' );
        	bufferedWriter.write("Nuc_line3: " + newdossier.getNuc_line3() + '\n' );
        	bufferedWriter.write("Nuc_line4: " + newdossier.getNuc_line4() + '\n' );
        	bufferedWriter.write("Nuc_line5: " + newdossier.getNuc_line5() + '\n' );
        	bufferedWriter.write("Nuc_line6: " + newdossier.getNuc_line6() + '\n' );
        	bufferedWriter.write("Inv_line1: " + newdossier.getInv_line1() + '\n' );
        	bufferedWriter.write("Inv_line2: " + newdossier.getInv_line2() + '\n' );
        	bufferedWriter.write("Inv_line3: " + newdossier.getInv_line3() + '\n' );
        	bufferedWriter.write("Inv_line4: " + newdossier.getInv_line4() + '\n' );
        	bufferedWriter.write("Inv_line5: " + newdossier.getInv_line5() + '\n' );
        	bufferedWriter.write("Inv_line6: " + newdossier.getInv_line6() + '\n' );
        	bufferedWriter.write("Rev_line1: " + newdossier.getRev_line1() + '\n' );
        	bufferedWriter.write("Rev_line2: " + newdossier.getRev_line2() + '\n' );
        	bufferedWriter.write("Rev_line3: " + newdossier.getRev_line3() + '\n' );
        	bufferedWriter.write("Rev_line4: " + newdossier.getRev_line4() + '\n' );
        	bufferedWriter.write("Rev_line5: " + newdossier.getRev_line5() + '\n' );
        	bufferedWriter.write("Rev_line6: " + newdossier.getRev_line6() + '\n' );
        	bufferedWriter.write("Fux_line1: " + newdossier.getFux_line1() + '\n' );
        	bufferedWriter.write("Fux_line2: " + newdossier.getFux_line2() + '\n' );
        	bufferedWriter.write("Fux_line3: " + newdossier.getFux_line3() + '\n' );
        	bufferedWriter.write("Fux_line4: " + newdossier.getFux_line4() + '\n' );
        	bufferedWriter.write("Fux_line5: " + newdossier.getFux_line5() + '\n' );
        	bufferedWriter.write("Fux_line6: " + newdossier.getFux_line6() + '\n' );
        	bufferedWriter.write("Username: " + newdossier.getUsername() + '\n' );
        	bufferedWriter.write("Categoryname: " + newdossier.getCategoryname() + '\n' );
        	bufferedWriter.write("Language: " + newdossier.getLanguagename() + '\n' );
        	bufferedWriter.write("Hexagramname: " + newdossier.getHexagramname() + '\n' );

            // Always close files.
            bufferedWriter.close();
        }
        catch(IOException ex) {
            System.out.println(
                "Error writing to file '"
                + fileName + "'");
        }
	}
}
    
